package com.cke.yang.security.api.dto.response;

import com.cke.yang.security.domain.entity.SecMenu;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yuyang
 */
@Getter
@Setter
public class SecMenuNodeResponse {

    /**
     * 菜单编码
     */
    private String menuCode;

    /**
     * 菜单路径
     */
    private String menuPath;

    /**
     * 菜单名称
     */
    private String menuName;

    /**
     * 菜单图标
     */
    private String icon;

    /**
     * 前端路径
     */
    private String webPath;

    /**
     * 是否启用
     */
    private Integer isEnabled;

    /**
     * 子菜单项
     */
    private List<SecMenuNodeResponse> child;

    public SecMenuNodeResponse(SecMenu menu) {
        this.menuCode = menu.getMenuCode();
        this.menuPath = menu.getMenuPath();
        this.menuName = menu.getMenuName();
        this.icon = menu.getIcon();
        this.webPath = menu.getWebPath();
        this.isEnabled = menu.getIsEnabled();
        this.child = new ArrayList<>();
    }

    /**
     * 添加子菜单节点
     *
     * @param childNode 子菜单节点
     */
    public void addChildNode(SecMenuNodeResponse childNode) {
        if (this.child == null) {
            this.child = new ArrayList<>();
        }
        this.child.add(childNode);
    }
    
}
